﻿
namespace Math2DStruct
{
    public struct Triangle
    {
        public XVector2 a;
        public XVector2 b;
        public XVector2 c;

        public Triangle(XVector2 a, XVector2 b, XVector2 c)
        {
            this.a = a;
            this.b = b;
            this.c = c;
        }

        public bool IsIn(XVector2 point)
        {
            var pa = a - point;
            var pb = b - point;
            var pc = c - point;

            var t1 = XVector3.Cross(pa.x0z, pb.x0z);
            var t2 = XVector3.Cross(pb.x0z, pc.x0z);
            var t3 = XVector3.Cross(pc.x0z, pa.x0z);

            if (t1.y * t2.y <= 0 || t1.y * t3.y <= 0)
                return false;
            else
                return true;
        }
    }
}
